package com.haierCamera.customapplication.utils;

import java.util.List;
import java.util.regex.Pattern;

public class StringUtils {

    public static String listToString1(List<String> list) {
        StringBuilder sb = new StringBuilder();
        if (list != null && list.size() > 0) {
            for (int i = 0; i < list.size(); i++) {
                if (i < list.size() - 1) {
                    sb.append(list.get(i) + ",");
                } else {
                    sb.append(list.get(i));
                }
            }
        }
        return sb.toString();
    }

    public static boolean isMatch(final String regex, final CharSequence input) {
        return input != null && input.length() > 0 && Pattern.matches(regex, input);
    }

    /**
     * 8到32位，符号，数字，字母
     * @param input
     * @return
     */
    public static boolean isTest(CharSequence input) {
        String regex = "^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)(?![,\\.#%'\\+\\*\\-:;^_`]+$)[,\\.#%'\\+\\*\\-:;^_`0-9A-Za-z]{8,32}$";
//        Pattern compile = Pattern.compile(regex);
//        Matcher matcher = compile.matcher(input.toString());
//        return matcher.find();
        return isMatch(regex, input);
    }

}
